package com.laifeng.sopcastsdk.configuration;

/**
 * @Title: VideoConfiguration
 * @Package com.laifeng.sopcastsdk.configuration
 * @Description:
 * @Author Jim
 * @Date 16/9/14
 * @Time 下午3:20
 * @Version
 */

public final class VideoConfiguration {

    public static final int DEFAULT_HEIGHT = 1280;
    public static final int DEFAULT_WIDTH = 720;
    public static final int DEFAULT_FPS = 15;
    public static final int DEFAULT_MAX_BPS = 1300;
    public static final int DEFAULT_MIN_BPS = 400;
    public static final int DEFAULT_IFI = 2;
    public static final String DEFAULT_MIME = "video/avc";

    public int height;
    public int width;
    public int minBps;
    public int maxBps;
    public int fps;
    public int ifi;
    public String mime; // must be default

    private static VideoConfiguration mRecordConfig;
    private static VideoConfiguration mLiveConfig;

    private VideoConfiguration() {
        height = DEFAULT_HEIGHT;
        width = DEFAULT_WIDTH;
        minBps = DEFAULT_MIN_BPS;
        maxBps = DEFAULT_MAX_BPS;
        fps = DEFAULT_FPS;
        ifi = DEFAULT_IFI;
        mime = DEFAULT_MIME;
    }

    public static synchronized VideoConfiguration getRecordingConfig() {
        if (mRecordConfig == null) {
            mRecordConfig = new VideoConfiguration()
                    .setSize(720, 1280)
                    .setBps(2000, 3000)
                    .setFps(25)
                    .setIfi(2);
        }

        return mRecordConfig;
    }

    public static synchronized VideoConfiguration getLivingConfig() {
        if (mLiveConfig == null) {
            mLiveConfig = new VideoConfiguration()
                    .setSize(480, 800)
                    .setBps(400, 1500)
                    .setFps(15)
                    .setIfi(2);
        }

        return mLiveConfig;
    }


    public VideoConfiguration setSize(int width, int height) {
        this.width = width;
        this.height = height;
        return this;
    }

    public VideoConfiguration setBps(int minBps, int maxBps) {
        this.minBps = minBps;
        this.maxBps = maxBps;
        return this;
    }

    public VideoConfiguration setFps(int fps) {
        this.fps = fps;
        return this;
    }

    public VideoConfiguration setIfi(int ifi) {
        this.ifi = ifi;
        return this;
    }
}


//public final class VideoConfiguration {
//    public static final int DEFAULT_HEIGHT = 1280;
//    public static final int DEFAULT_WIDTH = 720;
//    public static final int DEFAULT_FPS = 15;
//    public static final int DEFAULT_MAX_BPS = 1300;
//    public static final int DEFAULT_MIN_BPS = 400;
//    public static final int DEFAULT_IFI = 2;
//    public static final String DEFAULT_MIME = "video/avc";
//
//    public final int height;
//    public final int width;
//    public final int minBps;
//    public final int maxBps;
//    public final int fps;
//    public final int ifi;
//    public final String mime;
//
//    private VideoConfiguration(final Builder builder) {
//        height = builder.height;
//        width = builder.width;
//        minBps = builder.minBps;
//        maxBps = builder.maxBps;
//        fps = builder.fps;
//        ifi = builder.ifi;
//        mime = builder.mime;
//    }
//
//    public static class Builder {
//        private int height = DEFAULT_HEIGHT;
//        private int width = DEFAULT_WIDTH;
//        private int minBps = DEFAULT_MIN_BPS;
//        private int maxBps = DEFAULT_MAX_BPS;
//        private int fps = DEFAULT_FPS;
//        private int ifi = DEFAULT_IFI;
//        private String mime = DEFAULT_MIME;
//
//        public Builder setSize(int width, int height) {
//            this.width = width;
//            this.height = height;
//            return this;
//        }
//
//        public Builder setBps(int minBps, int maxBps) {
//            this.minBps = minBps;
//            this.maxBps = maxBps;
//            return this;
//        }
//
//        public Builder setFps(int fps) {
//            this.fps = fps;
//            return this;
//        }
//
//        public Builder setIfi(int ifi) {
//            this.ifi = ifi;
//            return this;
//        }
//
//        public Builder setMime(String mime) {
//            this.mime = mime;
//            return this;
//        }
//
//        public VideoConfiguration build() {
//            return new VideoConfiguration(this);
//        }
//    }
//
//    public static VideoConfiguration createRecordingDefault() {
//        return new Builder()
//                .setSize(720, 1280)
//                .setBps(2000, 3000)
//                .setFps(25)
//                .setIfi(2)
//                .setMime(DEFAULT_MIME)
//                .build();
//    }
//
//    public static VideoConfiguration createLivingDefault() {
//        return new Builder()
//                .setSize(480, 800)
//                .setBps(400, 1500)
//                .setFps(15)
//                .setIfi(1)
//                .setMime(DEFAULT_MIME)
//                .build();
//    }
//
//
//
//}
